#ifndef QGAMEVIDEO_H
#define QGAMEVIDEO_H
#include <QtWidgets>
#include <QMainWindow>
#include <QTimer>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QMessageBox>
#include <QWheelEvent>
#include <QTime>
#include <QThread>
#include <QMutex>
#include <QDebug>
#include "Custom_QGraphicsScene.h"
#include "dailyschedule.h"
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>

// COCO身体部位定义
const std::vector<std::string> BODY_PARTS_COCO = {
    "Nose", "Neck", "RShoulder", "RElbow", "RWrist", "LShoulder", "LElbow", "LWrist",
    "RHip", "RKnee", "RAnkle", "LHip", "LKnee", "LAnkle", "REye", "LEye", "REar", "LEar"
};

// 姿势连接对
const std::vector<std::pair<int, int>> POSE_PAIRS = {
    {1, 2}, {1, 5}, {2, 3}, {3, 4}, {5, 6}, {6, 7}, {1, 8}, {8, 9}, {9, 10}, {1, 11},
    {11, 12}, {12, 13}, {1, 0}, {0, 14}, {14, 16}, {0, 15}, {15, 17}
};

class qGameVideo : public QMainWindow
{
    Q_OBJECT

public:
    qGameVideo(QWidget* parent = nullptr);

    ~qGameVideo();
private:
    void setUiStyle();
    void initUi();
    void connectSignalToSolts();
private slots:
    //void captureFrame();
   // void updateDisplay(const QImage& image);


private:
    //地图绘制和点击事件
    CustomGraphicsView* graphicsView;
    QGraphicsScene* scene;


    //五子棋点击按钮
    QPushButton* m_btnGoBang;
    //视屏点击按钮
    QPushButton* m_btnVideo;
    //作息表
    QPushButton* m_btnSchedule;
    //笔记本
    QPushButton* m_ErrorNode;
    //音乐厅
    QPushButton* m_MusicHall;
    //聊天室
    QPushButton* m_ChatRoom;
    //登录界面
    QPushButton* m_btnLogin;
    //地图设计界面
    QPushButton* m_btnMaper;
    //pokemone按钮
    QPushButton* m_btnPokemon;
    //番茄钟
    QPushButton* m_btnTomato;


    //视屏界面
    QWidget* wgt_video;
    //五子棋页面
    QWidget* wgt_goBnag;
    //笔记界面
    QWidget* wgt_note;
    //录屏界面
    QWidget* wgt_record;
    //手机投屏界面
    QWidget* wgt_phone;
    //菜谱界面
    QWidget* wgt_recipe;
    //新闻界面
    QWidget* wgt_news;
    //设置界面
    QWidget* wgt_setting;
    //作息表界面
    QWidget* wgt_schedule;
    //登录界面
    QWidget* wgt_login;
    //番茄钟界面
    QWidget* wgt_tomato;
    
 


    //任务界面
    QWidget* wgt_task;
    //错题本界面
    QWidget* wgt_error;
    //音乐厅界面
    QWidget* wgt_music;
    //聊天室界面
    QWidget* wgt_chat;
    //地图设置界面
    QWidget* wgt_maper;
    //pokemone界面
    QWidget* wgt_pokemon;
   

    QStackedWidget* sgt;

private:
    QTimer* timer;

    cv::VideoCapture capture;
    cv::dnn::Net openPoseNet;
    bool openPoseLoaded;

    QThread* workerThread;

    int frameCounter;
    const int PROCESS_EVERY_N_FRAMES = 10; // 每2帧处理一次

   // void initializeCamera();
  //  void initializeOpenPose();

signals:
   // void frameToProcess(cv::Mat frame, bool openPoseLoaded);
};

#endif // QGAMEVIDEO_H